﻿using Microsoft.Extensions.Logging;
using NetCore.IRepository.OrderDrawingequipment;
using NetCore.Model.Enity;
using System;
using System.Threading.Tasks;

namespace NetCore.Repository.OrderDrawingequipment
{
    public class OrderDrawingequipmentRepository : BaseRepository<OrderDrawingequipmentBak>, IOrderDrawingequipmentRepository
    {
        private readonly ILogger<OrderDrawingequipmentRepository> _logger;

        public OrderDrawingequipmentRepository(ILogger<OrderDrawingequipmentRepository> Logger)
        {
            _logger = Logger;
        }

        /// <summary>
        /// 添加数据
        /// </summary>
        /// <returns></returns>
        public async Task<long> AddOrderDrawingequipmentBak(OrderDrawingequipmentBak orderDrawingequipmentBak)
        {
            try
            {
                long id = await Db.Insertable(new OrderDrawingequipmentBak()
                {
                    HeatNumber = orderDrawingequipmentBak.HeatNumber,
                    BatchNumber = orderDrawingequipmentBak.BatchNumber,
                    SpoolRfid = orderDrawingequipmentBak.SpoolRfid,
                    EquipmentId = orderDrawingequipmentBak.EquipmentId,
                    RawmaterialId = orderDrawingequipmentBak.RawmaterialId,
                    ShiftId = orderDrawingequipmentBak.ShiftId,
                    Weight = orderDrawingequipmentBak.Weight,
                    Yield = orderDrawingequipmentBak.Yield,
                    Userid = orderDrawingequipmentBak.Userid,
                    ProductionTime = orderDrawingequipmentBak.ProductionTime
                }).ExecuteReturnIdentityAsync();
                return id;
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message, ex);
                return 0;
            }
        }
    }
}